﻿using System;
using Microsoft.Xna.Framework;

namespace Phoenix.Xna.Framework.Components
{
    /// <summary>
    /// Defines the interface for all updatable components.
    /// </summary>
    public interface IComponent : IEngineComponent, IDisposableEx
    {
        /// <summary>
        /// Raised when the update order for the component has changed.
        /// </summary>
        event EventHandler<UpdateOrderChangedEventArgs> UpdateOrderChanged;

        /// <summary>
        /// Gets or sets a value indicating that the component is enabled.
        /// </summary>
        bool Enabled { get; set; }

        /// <summary>
        /// Gets or sets the order in which this component is updated compared to all other components managed by the engine.
        /// Lower values are updated sooner.
        /// </summary>
        int UpdateOrder { get; set; }

        /// <summary>
        /// Gets a value indicating that the component is initialized.
        /// </summary>
        bool IsInitialized { get; }

        /// <summary>
        /// Gets or sets the component's collection of sub-components.
        /// </summary>
        ComponentCollection SubComponents { get; set; }

        /// <summary>
        /// Initializes all non-graphics related content for the component.
        /// </summary>
        void Initialize();

        /// <summary>
        /// Updates the component.
        /// </summary>
        /// <param name="gameTime">The snapshot of elapsed game time.</param>
        void Update(GameTime gameTime);
    }
}
